package org.apache.james.hibernate.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

import org.apache.james.api.imap.ImapConstants;
import org.apache.james.mailboxmanager.Namespace;

@Entity
public class NamespaceImpl implements Namespace {

	int id;
	String name;
	
	String description;
	
	String repository;
	
	boolean defaultShared;
	
	boolean defaultUser;

	public NamespaceImpl() {
	}

	public NamespaceImpl(String name) {
		this.name = name;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRepository() {
		return repository;
	}

	public void setRepository(String repository) {
		this.repository = repository;
	}

	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public boolean isDefaultShared() {
		return defaultShared;
	}

	public void setDefaultShared(boolean defaultShared) {
		this.defaultShared = defaultShared;
	}

	public boolean isDefaultUser() {
		return defaultUser;
	}

	public void setDefaultUser(boolean defaultUser) {
		this.defaultUser = defaultUser;
	}

	@Override
	@Transient
	public String getHierarchyDelimter() {
		return ImapConstants.HIERARCHY_DELIMITER;
	}
	
	/**
	 * return the name of the full mailbox including the namespace.
	 * 
	 * @param mailbox
	 * @return
	 */
	@Transient
	public String getMailboxName(String mailbox) {
		return getName() + getHierarchyDelimter() + mailbox;
	}
}
